import type { App } from 'vue'
import { createRouter, createWebHashHistory, RouteRecordRaw } from 'vue-router'
import Layout from '../layout/index.vue'
import { createRouterGuard } from './guard'

const routes: RouteRecordRaw[] = [
  {
    path: '/',
    component: Layout,
    redirect: '/energyMonitor/dataMonitor',
    children: [
      {
        meta: { title: '综合展示', icon: 'zhzs-icon' },
        path: 'zhzs',
        name: 'zhzs',
        children: [],
      },
      {
        meta: { title: '能源实时监测', icon: 'nyssjc-icon' },
        path: '/energyMonitor',
        name: 'energyMonitor',
        children: [
          {
            meta: { title: '实时数据监测' },
            path: '/energyMonitor/dataMonitor',
            component: () => import('@/views/energyMonitor/dataMonitor/index.vue'),
            name: 'dataMonitor',
          },
          {
            meta: { title: '电力一张图' },
            path: '/energyMonitor/powerDiagram',
            component: () => import('@/views/energyMonitor/powerDiagram/index.vue'),
            name: 'powerDiagram',
          },
          {
            meta: { title: '蒸汽一张图' },
            path: '/energyMonitor/steamDiagram',
            component: () => import('@/views/energyMonitor/steamDiagram/index.vue'),
            name: 'steamDiagram',
          },
          {
            meta: { title: '石化基地能流图' },
            path: '/energyMonitor/petrochemicalDiagram',
            component: () => import('@/views/energyMonitor/petrochemicalDiagram/index.vue'),
            name: 'petrochemicalDiagram',
          },
          {
            meta: { title: '能源监测地图' },
            path: '/energyMonitor/energyMonitoringMap',
            component: () => import('@/views/energyMonitor/energyMonitoringMap/index.vue'),
            name: 'energyMonitoringMap',
          },
          {
            meta: { title: '历史数据查询' },
            path: '/energyMonitor/historicalData',
            component: () => import('@/views/energyMonitor/historicalData/index.vue'),
            name: 'historicalData',
          },
        ],
      },
      {
        meta: { title: '能耗统计', icon: 'nhtj-icon' },
        path: '/energyConsumption',
        name: 'energyConsumption',
        children: [
          {
            meta: { title: '能耗数据统计' },
            path: '/energyConsumption/dataConsumption',
            component: () => import('@/views/energyConsumption/dataConsumption/index.vue'),
            name: 'dataConsumption',
          },
          {
            meta: { title: '能源双控进度' },
            path: '/energyConsumption/doubleControlProgress',
            component: () => import('@/views/energyConsumption/doubleControlProgress/index.vue'),
            name: 'doubleControlProgress',
          },
          {
            meta: { title: '能源结构分析' },
            path: '/energyConsumption/structuralAnalysis',
            component: () => import('@/views/energyConsumption/structuralAnalysis/index.vue'),
            name: 'structuralAnalysis',
          },
          {
            meta: { title: '能耗损率分析' },
            path: '/energyConsumption/lossRateAnalysis',
            component: () => import('@/views/energyConsumption/lossRateAnalysis/index.vue'),
            name: 'lossRateAnalysis',
          },
        ],
      },
      {
        meta: { title: '监测报警分析', icon: 'jcbjfx-icon' },
        path: '/monitorAlarmAnalysis',
        name: 'monitorAlarmAnalysis',
        children: [
          {
            meta: { title: '告警统计分析' },
            path: '/monitorAlarmAnalysis/notificationAnalytics',
            component: () => import('@/views/monitorAlarmAnalysis/notificationAnalytics/index.vue'),
            name: 'notificationAnalytics',
          },
          {
            meta: { title: '监测报警记录' },
            path: '/monitorAlarmAnalysis/notificationRecords',
            component: () => import('@/views/monitorAlarmAnalysis/notificationRecords/index.vue'),
            name: 'notificationRecords',
          },
          {
            meta: { title: '报警配置' },
            path: '/monitorAlarmAnalysis/alarmConfiguration',
            component: () => import('@/views/monitorAlarmAnalysis/alarmConfiguration/index.vue'),
            name: 'alarmConfiguration',
          },
          // {
          //   meta: { title: '报警配置变更记录' },
          //   path: '/monitorAlarmAnalysis/alarmConfigurationChange',
          //   component: () =>
          //     import('@/views/monitorAlarmAnalysis/alarmConfigurationChange/index.vue'),
          //   name: 'alarmConfigurationChange',
          // },
          {
            meta: { title: '安全告警周报' },
            path: '/monitorAlarmAnalysis/weeklyAlarmReport',
            component: () => import('@/views/monitorAlarmAnalysis/weeklyAlarmReport/index.vue'),
            name: 'weeklyAlarmReport',
          },
        ],
      },
      {
        meta: { title: '能效分析', icon: 'nxfx-icon' },
        path: '/efficiencyAnalysis',
        name: 'efficiencyAnalysis',
        children: [
          {
            meta: { title: '综合能效水平分析' },
            path: '/efficiencyAnalysis/compEfficiencyAnalysis',
            component: () => import('@/views/efficiencyAnalysis/compEfficiencyAnalysis/index.vue'),
            name: 'compEfficiencyAnalysis',
          },
          {
            meta: { title: '节能项目管理' },
            path: '/efficiencyAnalysis/energyProjMan',
            component: () => import('@/views/efficiencyAnalysis/energyProjMan/index.vue'),
            name: 'energyProjMan',
          },
          {
            meta: { title: '能耗对标分析' },
            path: '/efficiencyAnalysis/energyBenchmarking',
            component: () => import('@/views/efficiencyAnalysis/energyBenchmarking/index.vue'),
            name: 'energyBenchmarking',
          },
          {
            meta: { title: '能耗趋势分析' },
            path: '/efficiencyAnalysis/trendAnalysis',
            component: () => import('@/views/efficiencyAnalysis/trendAnalysis/index.vue'),
            name: 'trendAnalysis',
          },
        ],
      },
      // {
      //   meta: { title: '评估与调度', icon: 'pgydd-icon' },
      //   path: 'pgydd',
      //   name: '',
      //   children: [],
      // },
      // {
      //   meta: { title: '报表管理', icon: 'bbgl-icon' },
      //   path: 'bbgl',
      //   name: '',
      //   children: [],
      // },
      {
        meta: { title: '项目用能管理', icon: 'xmyngl-icon' },
        path: '/projectEnergy',
        name: 'projectEnergy',
        children: [
          {
            meta: { title: '项目能耗管理' },
            path: '/projectEnergy/projectEnergyConsumption',
            component: () => import('@/views/projectEnergy/projectEnergyConsumption/index.vue'),
            name: 'projectEnergyConsumption',
          },
        ],
      },
      {
        meta: { title: '系统管理', icon: 'xtgl-icon' },
        path: '/systemManage',
        name: 'systemManage',
        children: [
          {
            meta: { title: '园区信息管理' },
            path: '/systemManage/parkInfo',
            component: () => import('@/views/systemManage/parkInfo/index.vue'),
            name: 'parkInfo',
          },
          {
            meta: { title: '企业对象管理' },
            path: '/systemManage/enterpriseObject',
            component: () => import('@/views/systemManage/enterpriseObject/index.vue'),
            name: 'enterpriseObject',
          },
          {
            meta: { title: '监测点位管理' },
            path: '/systemManage/monitoringPoint',
            component: () => import('@/views/systemManage/monitoringPoint/index.vue'),
            name: 'monitoringPoint',
          },
          {
            meta: { title: '园区能效指标配置' },
            path: '/systemManage/parkEnergyEffIndex',
            component: () => import('@/views/systemManage/parkEnergyEffIndex/index.vue'),
            name: 'parkEnergyEffIndex',
          },
          {
            meta: { title: '企业能效指标配置' },
            path: '/systemManage/enterpriseEnergyEffIndex',
            component: () => import('@/views/systemManage/enterpriseEnergyEffIndex/index.vue'),
            name: 'enterpriseEnergyEffIndex',
          },
          {
            meta: { title: '能源折标系数配置' },
            path: '/systemManage/energyConversionCoeff',
            component: () => import('@/views/systemManage/energyConversionCoeff/index.vue'),
            name: 'energyConversionCoeff',
          },
        ],
      },
    ],
  },
  {
    path: '/404',
    component: () => import(/* webpackChunkName: "dashboard" */ '../views/error/index.vue'),
    name: 'error',
    meta: {
      title: 'error',
      icon: '#icondashboard',
      affix: true,
    },
  },
]

export const router = createRouter({
  /** 打包配置二级路径 */
  // history: createWebHashHistory('readiness'),
  history: createWebHashHistory(),
  routes,
})

export async function setupRouter(app: App) {
  app.use(router)
  createRouterGuard(router)
  await router.isReady()
}
